
package com.thalesgroup.nl.trtdelft.dein.mapper.example;

import com.thalesgroup.nl.trtdelft.dein.mapper.AbstractMappedWebService;
import com.thalesgroup.nl.trtdelft.dein.servlet.impl.Client;
import java.io.IOException;
import java.io.Serializable;
import java.net.URISyntaxException;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.http.HttpException;
import org.json.simple.JSONObject;

/**
 *
 * @author AbdelhaqA
 */
public class YahooHotelService extends AbstractMappedWebService {   
    @Override
    @SuppressWarnings("unchecked")
    public void input(String senderAddress, String inputVariableName, Serializable input) {
    }
         
    
    
    @Override
    public void start() {
        
        JSONObject args = new JSONObject();
//            String ac = "13103";
//            String gc = "0304";
        String ac = (String) queryReceiveVariableContent.get("addressCode"); 
        String gc = (String) queryReceiveVariableContent.get("genreCode");           
        try {
        String HotelList = Client.get("http://search.olp.yahooapis.jp/OpenLocalPlatform/V1/localSearch?appid=dj0zaiZpPW04aDNSeU5tRWZLbSZzPWNvbnN1bWVyc2VjcmV0Jng9NTM-&ac="+ac+"&gc="+gc, args.toJSONString());
        outputs.put("listOfHotels", HotelList);
      //  sendMapperInformationInterface.sendOutput();
        } catch (HttpException ex) {
            Logger.getLogger(YahooHotelService.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(YahooHotelService.class.getName()).log(Level.SEVERE, null, ex);
        } catch (URISyntaxException ex) {
            Logger.getLogger(YahooHotelService.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    @Override
    public void computeOutput(String variableName) throws IllegalStateException {
        computeOutput();
    }
    @Override
    public Serializable getCurrentOutput(String variableName) throws IllegalStateException {
        return outputs.get(variableName);
    }

}
